package ru.jexp.rcp.supply.n.tableviewer;

import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;

import ru.jexp.rcp.supply.mui.JExpSupplyMessages;
import ru.jexp.rcp.supply.viewer.JExpTableLabelProvider;

public class TableViewerRazdelOkv extends TableViewer
{

	private MenuManager contextMenu;

	public TableViewerRazdelOkv(Composite parent)
	{
		super(parent, SWT.SINGLE | SWT.FULL_SELECTION);
		setUseHashlookup(true);
		getTable().setHeaderVisible(true);
		getTable().setLinesVisible(true);

		new JExpTableLabelProviderRazdelOkv().createColumns(this);
		
		createContextMenu();
	}
	
	public MenuManager getContextMenu()
	{
		return contextMenu;
	}
	
	private void createContextMenu()
	{
		contextMenu = new MenuManager();
		getTable().setMenu(contextMenu.createContextMenu(getTable()));
	}

	private class JExpTableLabelProviderRazdelOkv extends JExpTableLabelProvider
	{

		@Override
		public Object getValue(Object element, int columnIndex)
		{
			throw new RuntimeException();
		}

		@Override
		protected String[] createNameColumns()
		{
			return new String[] {	JExpSupplyMessages.Global_field_number,
									JExpSupplyMessages.Global_field_name };
		}

	}
}
